<?php

namespace app\api\model;

use think\Model;
use traits\think\Instance;

/**
 * member类 
 * @author      lixin 
 * @version     1.0 版本号
 */
class Plan extends Model
{

    protected $insert = ['c_datetime', 'member_id', 'state' => 0];
    protected $auto = ['u_datetime'];
    protected $update = [];

    protected static function init()
    {
        self::beforeInsert(function ($data) {
//            if ($user->status != 1)
//            {
//                return false;
//            }
        });
    }

    protected function setPDatetimeAttr($value = '', $data = [])
    {
        if (!empty($value))
        {
            return to_date($value);
        }
    }

    protected function setCDatetimeAttr($value = '', $data = [])
    {
        if (empty($value))
        {
            return to_date($_SERVER['REQUEST_TIME']);
        }
    }

    protected function setUDatetimeAttr($value = '', $data = [])
    {
        if (empty($value))
        {
            return to_date($_SERVER['REQUEST_TIME']);
        }
    }

    protected function setMemberIdAttr($value = '', $data = [])
    {
        if (empty($value))
        {
            return session('member_id');
        }
    }

    protected  function setStatedAttr($value = '', $data = [])
    {
        if (empty($value))
        {
            return 0;
        }
    }
}
